import { _decorator, Component, Node } from 'cc';
import { NodePool } from '../../../../sgame/pool/NodePool';
import { UIHint } from '../hint/UIHint';
const { ccclass, property } = _decorator;

@ccclass('UIHintLayer')
export class UIHintLayer extends Component {
    @property(NodePool)
    public pool: NodePool;

    public show(text: string): void {
        let hintNode: Node = this.pool.get();
        let hint: UIHint = hintNode.getComponent(UIHint);
        hint.onHide = this.hide.bind(this);
        hint.show(text);
    }

    public hide(hintNode: Node): void {
        this.pool.put(hintNode);
    }
}